
% cd ..
function interference(I0_name,I0_path,gray)
I0 = load(I0_path+"UF"+I0_name+".mat");
UF = I0.UF;

I0_k = I0_name(strlength(I0_name));
I0_k = str2double(I0_k);
if I0_k == 1
    lamb = 0.000650;
elseif I0_k == 2
    lamb = 0.000520;
elseif I0_k == 3
    lamb = 0.000450;
end

k=2*pi/lamb;

rh = 10000;
ch = 10000;
spdh = 3.18e-4;
Lx=spdh*ch;  
Ly=spdh*rh;
xR = linspace(-Lx/2,Lx/2,ch);
yR = linspace(-Ly/2,Ly/2,rh);
[xR,yR] = meshgrid(xR,yR);

R=k*yR*sind(0)+k*xR*sind(0); 
II=abs(UF).*cos(angle(UF)-R);
if gray
   II(II>=0)=255;
   II(II<0)=0;
end
II=(II-min(min(II)))./(max(max(II))-min(min(II)))*255;
[AAA,map]=imread("tg1-gray.bmp");
imwrite(II,map,I0_name+".bmp");
end